package edu.gdkm.dao;

import edu.gdkm.pojo.StudentInfo;
import org.apache.ibatis.annotations.*;
import java.util.List;

public interface StudentInfoDAO {
    
    // 根据ID查询学生信息
    @Select("SELECT * FROM student_info WHERE id = #{id}")
    StudentInfo findById(Long id);
    
    // 根据用户ID查询学生信息
    @Select("SELECT * FROM student_info WHERE user_id = #{userId}")
    StudentInfo findByUserId(Long userId);
    
    // 根据真实姓名查询学生信息
    @Select("SELECT * FROM student_info WHERE real_name = #{realName}")
    List<StudentInfo> findByRealName(String realName);
    
    // 查询所有学生信息
    @Select("SELECT * FROM student_info")
    List<StudentInfo> findAll();
    
    // 根据学校查询学生信息
    @Select("SELECT * FROM student_info WHERE university = #{university}")
    List<StudentInfo> findByUniversity(String university);
    
    // 根据专业查询学生信息
    @Select("SELECT * FROM student_info WHERE major = #{major}")
    List<StudentInfo> findByMajor(String major);
    
    // 插入学生信息
    @Insert("INSERT INTO student_info(user_id, real_name, gender, birthday, id_card, university, major, education, " +
            "graduation_time, political_status, hometown, current_city, job_intention, job_type, salary_expectation, " +
            "self_introduction, create_time, update_time) " +
            "VALUES(#{userId}, #{realName}, #{gender}, #{birthday}, #{idCard}, #{university}, #{major}, #{education}, " +
            "#{graduationTime}, #{politicalStatus}, #{hometown}, #{currentCity}, #{jobIntention}, #{jobType}, " +
            "#{salaryExpectation}, #{selfIntroduction}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(StudentInfo studentInfo);
    
    // 更新学生信息
    @Update("UPDATE student_info SET user_id=#{userId}, real_name=#{realName}, gender=#{gender}, birthday=#{birthday}, " +
            "id_card=#{idCard}, university=#{university}, major=#{major}, education=#{education}, graduation_time=#{graduationTime}, " +
            "political_status=#{politicalStatus}, hometown=#{hometown}, current_city=#{currentCity}, job_intention=#{jobIntention}, " +
            "job_type=#{jobType}, salary_expectation=#{salaryExpectation}, self_introduction=#{selfIntroduction}, " +
            "update_time=#{updateTime} WHERE id=#{id}")
    int update(StudentInfo studentInfo);
    
    // 根据ID删除学生信息
    @Delete("DELETE FROM student_info WHERE id = #{id}")
    int deleteById(Long id);
    
    // 根据用户ID删除学生信息
    @Delete("DELETE FROM student_info WHERE user_id = #{userId}")
    int deleteByUserId(Long userId);
}
